import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import { titleController } from "@/utils";

if (!window.VueRouter) { // 使用cdn引入会 导入全局 已经注册了 不能注册组件
    Vue.use(VueRouter)
}



const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})


router.afterEach((to, from) => {
    if (to.meta.title) {
        titleController.setRouteTitle(to.meta.title);
    }
})
export default router
